Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

detect/bsize: Validate against content buffer when available #5028

Closed
wants to merge 3 commits into from

Conversation

jlucovsky
Copy link
Contributor

Continuation of #5014

This PR adds additional validation when using the bsize keyword. If a one or more content keywords immediately precedes bsize, then the bsize value is checked against each to see if a match is possible using the operation (=, <, >, <>) and the value.

An error is raised if bsize value prevents a match, e.g., the content length exceeds the bsize value. The bsize operation and values are used to do the evaluation.

Link to redmine ticket: 3682

Describe changes:

  • Address review comments

Companion Suricata PR #233

This commit updates the bsize documentation

1. Describe what happens when "content" immediately precedes "bsize"
2. Include the operators and
3. Include examples using the operators.
This commit causes the signature to be invalid if a content keyword
immediately precedes bsize and the bsize value is incompatible with the
content length.
This commit adds test cases that validate behavior when "content"
immediately precedes "bsize".
@catenacyber
Copy link
Contributor

Could we use detect-engine-uint.c helper functions ?

@jlucovsky
Copy link
Contributor Author

Could we use detect-engine-uint.c helper functions ?

I don't think that would be a benefit in this case. DetectCheckValue has different semantics than the match function in detect-engine-uint.c.

@victorjulien victorjulien added this to the 7.0 milestone Sep 7, 2020

.. container:: example-rule

alert dns any any -> any any (msg:"test bsize rule"; dns.query; content:"middle"; bsize:5<>15; sid:126; rev:1;)
Copy link
Member

@inashivb inashivb Oct 6, 2020

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This should probably be bsize:6<>15 as length of "middle" is 6.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

What does 6<>15 mean ? A range ?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yes -- a range.

@jlucovsky
Copy link
Contributor Author

Continued in #5576

@jlucovsky jlucovsky closed this Nov 18, 2020
@jlucovsky jlucovsky deleted the 3682/8 branch April 24, 2024 12:15
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Development

Successfully merging this pull request may close these issues.

4 participants